<?php

use yii\helpers\Html;
use kartik\grid\GridView;
use kartik\datetime\DateTimePicker;
use  yii\widgets\ActiveForm;
use backend\modules\goods\models\Goods;
/* @var $this yii\web\View */
/* @var $searchModel backend\modules\pooai\models\search\ZpooaiPagesSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = Yii::t('app', '商品列表');
$this->params['breadcrumbs'][] = $this->title;
$this->registerCssFile('@web/css/admin.css');
?>
<?php $form = ActiveForm::begin([
    'action' =>['/goods/goods/index'],
    'method' => 'post'
]);?>
<div class="zpooai-pages-index">
    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        'filterModel' => $searchModel,
        'containerOptions'=>['style'=>'overflow: auto'], // only set when $responsive = false
        'headerRowOptions'=>['class'=>'kartik-sheet-style'],
        'filterRowOptions'=>['class'=>'kartik-sheet-style'],
        'columns' => [
            [
                'class' => '\kartik\grid\CheckboxColumn',
            ],
            [
                'class' => 'yii\grid\SerialColumn',
            ],

            [
                'label'=>'商品名称',
                'format'=>'raw',
                'attribute' => 'goods_name',/*产生一个a标签,点击可排序*/
                'contentOptions' => ['style' => 'vertical-align: middle;', 'width' => '200px'],
                'value'=>function($m){
                    return $m->goods_name;
                }
            ],

            [
                'label'=>'商品图片',
                'format'=>'raw',
                'attribute' => 'goods_image',/*产生一个a标签,点击可排序*/
                'contentOptions' => [ 'width' => '200px'],
                'value'=>function($m){
                    return Html::img('../'.$m->goods_image,['alt' => '商品图片','width' => 80]);
                }],

            [
                'label'=>'是否精品',
                'attribute' => 'is_good',
                'class'=>'kartik\grid\EditableColumn',
                'editableOptions'=>[
                    'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                    'asPopover' => false,
                    'data' => Goods::isGoodAlias("all"),
                ],
                'value' => function ($model) {
                    return Goods::isGoodAlias($model->is_good);
                },
                'filter' => Goods::isGoodAlias("all"),
            ],

            [
                'label'=>'是否新品',
                'attribute' => 'is_new',
                'class'=>'kartik\grid\EditableColumn',
                'editableOptions'=>[
                    'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                    'asPopover' => false,
                    'data' => Goods::isNewAlias("all"),
                ],
                'value' => function ($model) {
                    return Goods::isNewAlias($model->is_new);
                },
                'filter' => Goods::isNewAlias("all"),
            ],

            [
                'label'=>'是否热销',
                'attribute' => 'is_hot',
                'class'=>'kartik\grid\EditableColumn',
                'editableOptions'=>[
                    'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                    'asPopover' => false,
                    'data' => Goods::isHotAlias("all"),
                ],
                'value' => function ($model) {
                    return Goods::isHotAlias($model->is_hot);
                },
                'filter' => Goods::isHotAlias("all"),
            ],

            [
                'label'=>'是否下架',
                'attribute' => 'is_delete',
                'class'=>'kartik\grid\EditableColumn',
                'editableOptions'=>[
                    'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                    'asPopover' => false,
                    'data' => Goods::isDeleteAlias("all"),
                ],
                'value' => function ($model) {
                    return Goods::isDeleteAlias($model->is_delete);
                },
                'filter' => Goods::isDeleteAlias("all"),
            ],

            [
                'label'=>'是否促销',
                'attribute' => 'is_promote',
                'class'=>'kartik\grid\EditableColumn',
                'editableOptions'=>[
                    'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                    'asPopover' => false,
                    'data' => Goods::isPromoteAlias("all"),
                ],
                'value' => function ($model) {
                    return Goods::isPromoteAlias($model->is_promote);
                },
                'filter' => Goods::isPromoteAlias("all"),
            ],

            [
                'label'=>'是否单品',
                'attribute' => 'is_single',
                'class'=>'kartik\grid\EditableColumn',
                'editableOptions'=>[
                    'inputType'=>\kartik\editable\Editable::INPUT_DROPDOWN_LIST,
                    'asPopover' => false,
                    'data' => Goods::isSingleAlias("all"),
                ],
                'value' => function ($model) {
                    return Goods::isSingleAlias($model->is_single);
                },
                'filter' => Goods::isSingleAlias("all"),
            ],



            [
                'class' => 'kartik\grid\ActionColumn',
                'headerOptions' => ['class' => 'kartik-sheet-style'],
            ],
        ],


        'export' => false,
        'responsive' => true,
        'panel' => [
            'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-globe"></i> ' .Yii::t('Wxuser','商品列表'). '</h3>',
            'type' => 'success',
            'before' => Html::a('<i class="glyphicon glyphicon-plus"></i>' . Yii::t('Wxuser','创建商品'), ['create'], ['class' => 'btn btn-success']),
            'footer' => false,
            'after' => false
        ],
        'toolbar' => [
            [
                'content' =>
                    Html::dropDownList('act', '',
                        [
                            '' => Yii::t('Wxuser','选择操作') ,
                            'delete' =>  Yii::t('Wxuser','删除') ,

                        ],
                        ['class' => 'btn btn-default', 'style' => 'margin-right:10px']) . Html::submitButton( Yii::t('Wxuser','保存'), ['class' => 'btn btn-success']),
                'options' => ['class' => 'btn-group-sm'],
                '{export}',
                '{toggleData}'
            ],
            'toggleDataContainer' => ['class' => 'btn-group-sm'],
            'exportContainer' => ['class' => 'btn-group-sm']
        ]
    ]); ?>
</div>
<?php ActiveForm::end(); ?>
